from django.http import HttpResponseRedirect


#验证学生
def check_student(func):

	def check_st(request,*args,**kwargs):
		if 'u_type' in request.session and request.session.get('u_type','')=='student':
			return func(request,*args,**kwargs)
		return HttpResponseRedirect('/evaluate/login/')
	return check_st

#验证参与评价的教师
def check_teacher(func):
	def check_t(request,*args,**kwargs):
		if 'u_type' in request.session and request.session.get('u_type','')=='teacher':
			return func(request,*args,**kwargs)
		return HttpResponseRedirect('/evaluate/login/')
	return check_t

#验证管理员
def check_admin(func):
	def check_a(request,*args,**kwargs):
		if 'u_type' in request.session :
			if  request.session.get('u_type','')=='超级管理员' or request.session.get('u_type','')=='管理员':
				return func(request,*args,**kwargs)
		return HttpResponseRedirect('/evaluate/admin_login/')
	return check_a